#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
int rot(char* a,char* b)
{
	int i = 0, j = 0;
	char t;
	int len = strlen(a);
	int flag = 0;
	for (i = 0; i < len; i++)
	{
		t = a[0];
		for (j = 0; j < len - 1; j++)
		{
			a[j] = a[j + 1];
		}
		a[j] = t;
		if (strcmp(a, b) == 0)
		{
			flag = 1;
			break;
		}
	}
	
	return flag;
}
int main()
{
	int k = 0;
	char s1[1001], s2[1001];
	scanf("%s %s",s1,s2);
	printf("%d",rot(s1,s2));
	return 0;
}